package com.jhx.mall.dao.impl;

import com.jhx.mall.dao.BaseDao;
import com.jhx.mall.dao.DtsBrandDao;
import com.jhx.mall.entity.DtsBrand;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class DtsBrandDaoImpl extends BaseDao implements DtsBrandDao {
    @Override
    public List<DtsBrand> selectAll() {
        List<DtsBrand> dtsBrandList = new ArrayList<>();
        String sql = "select id, name, `desc`, pic_url, floor_price, sort_order, add_time, update_time, deleted, commpany, auto_update_good, shop_url, default_category_id, default_pages, add_precent, address, longitude, latitude, fetch_time_rules from dts_brand where deleted = 0";
        rs = executeQuery(sql);
        try {
            while (rs.next()) {
                DtsBrand dtsBrand = new DtsBrand();
                dtsBrand.setId(rs.getLong("id"));
                dtsBrand.setName(rs.getString("name"));
                dtsBrand.setDesc(rs.getString("desc"));
                dtsBrand.setPicUrl(rs.getString("pic_url"));
                dtsBrand.setFloorPrice(rs.getDouble("floor_price"));
                dtsBrand.setSortOrder(rs.getLong("sort_order"));
                dtsBrand.setAddTime(rs.getString("add_time"));
                dtsBrand.setUpdateTime(rs.getString("update_time"));
                dtsBrand.setDeleted(rs.getLong("deleted"));
                dtsBrand.setCommpany(rs.getString("commpany"));
                dtsBrand.setAutoUpdateGood(rs.getLong("auto_update_good"));
                dtsBrand.setShopUrl(rs.getString("shop_url"));
                dtsBrand.setDefaultCategoryId(rs.getLong("default_category_id"));
                dtsBrand.setDefaultPages(rs.getLong("default_pages"));
                dtsBrand.setAddPrecent(rs.getLong("add_precent"));
                dtsBrand.setAddress(rs.getString("address"));
                dtsBrand.setLongitude(rs.getDouble("longitude"));
                dtsBrand.setLatitude(rs.getDouble("latitude"));
                dtsBrand.setFetchTimeRules(rs.getString("fetch_time_rules"));
                dtsBrandList.add(dtsBrand);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            super.closeAll(rs, pstmt, conn);
        }
        return dtsBrandList;
    }
}
